Rework TestEnv and Implement Client::get_prune_height#42
Rework TestEnv and Implement Client::get_prune_height#42luisschwab wants to merge 2 commits intobitcoindevkit:masterfrom
TestEnv and Implement Client::get_prune_height#42Conversation
Also exposes a`corepc_node::Client` in the `TestEnv`.
7d3798a to
7b26c34
Compare
tvpeter
left a comment
There was a problem hiding this comment.
Hi @luisschwab, I left a few comments.
Implement `Client::get_prune_height`, calling `getblockchaininfo` under the hood, and returns: - `None`, if `bitcoind` is not pruned, - `Some(u32)` with the prune height, if `bitcoind` is pruned.
7b26c34 to
b4536a9
Compare
|
Can you share the error? CI and local testing is passing for me. |
|
This looks like a race condition happening on your local |
|
Try adding a timeout after the #[test]
fn test_get_prune_height() {
// Spawn an unpruned node.
let env_unpruned = TestEnv::new();
// Assert that `getblockchaininfo.pruned` is `None`.
let unpruned_res = env_unpruned.client.get_prune_height().unwrap();
assert_eq!(unpruned_res, None);
// Spawn a node with manual pruning enabled.
let mut node_config = Conf::default();
node_config.args.push("-prune=1");
node_config.args.push("-fastprune");
let env_pruned = TestEnv::new_with_config(&node_config);
// Mine 1000 blocks.
let block_count = 1000;
let _hashes = env_pruned.mine_blocks(block_count as usize, None);
// Assert that `getblockchaininfo.pruned` is `Some(0)`.
let pruned_res = env_pruned.client.get_prune_height().unwrap();
assert_eq!(pruned_res, Some(0));
// Prune the last 2 blocks.
let _ = env_pruned.corepc_client.prune_blockchain(block_count - 2);
+ std::thread::sleep(std::time::Duration::from_secs(2));
// Assert that `getblockchaininfo.prunedheight` is > 0.
// Note: it's not possible to assert on a specific block height since Bitcoin Core
// prunes at the block file level (`blkXXXX.dat`), and not at block height level.
let pruned_res = env_pruned.client.get_prune_height().unwrap();
assert!(pruned_res > Some(0));
} |
|
|
Did you set |
I have set it to point to my |
|
Try unsetting |
I have done that, and it's still the same output. This is clogging this PR conversation, so let's wait for others to confirm, then I will revert to check the reason it's failing on my end. Thank you. |

Closes #40
Changelog